package response

import "net/http"

type Result[T any] struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    T      `json:"data"`
}

//Success 成功
func Success[T any](data T) Result[T] {
	return Result[T]{Code: http.StatusOK, Message: "成功", Data: data}
}

//SuccessWithMessage 包含消息的成功
func SuccessWithMessage[T any](data T, message string) Result[T] {
	return Result[T]{Code: http.StatusOK, Message: message, Data: data}
}

//Erro 失败
func Erro(message string) Result[any] {
	return Result[any]{Code: http.StatusInternalServerError, Message: message, Data: nil}
}
